\documentclass[12pt,oneside,a4paper]{report}
\usepackage{graphicx}
\usepackage[most]{tcolorbox}
\usepackage{float}
\usepackage{pdflscape}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{longtable}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=red,
    urlcolor=black
}
\tcbset{
    frame code={}
    center title,
    left=0pt,
    right=0pt,
    top=0pt,
    bottom=0pt,
    colback=gray!70,
    colframe=white,
    width=\dimexpr\textwidth\relax,
    enlarge left by=0mm,
    boxsep=5pt,
    arc=0pt,outer arc=0pt,
}
\begin{document}
    \begin{titlepage}
       \begin{center}
          {\huge\bfseries Dockerfile Audit Report}\\
          % ----------------------------------------------------------------
          \vspace{1.5cm}
          {\Large\bfseries Security Team}\\[5pt]
% ----------------------------------------------------------------
          \vspace{2cm}
          {\Large \today}\\[5pt]
          \vspace{2cm}
          \includegraphics[width=8cm]{images/logo.png}
          \vfill
          \vfill
          \small{Confidential}
          \vfill
       \end{center}
    \end{titlepage}
    \tableofcontents
    \chapter{Summary}
       The auditing was completed on \today.
\linebreak
       An overview of the results is presented in the table below.
\\

       \begin{table}[h!]
          \large
          \begin{tabular}{| p{0.5\textwidth} | p{0.2\textwidth} | p{0.2\textwidth} |}
             \hline
             \textbf{Total Dockerfile tested} & \VAR{summary_stats["total_tests"]} & 100\% \\ \hline
             \textbf{Audit Passed} & \VAR{summary_stats["success_tests"]} & \VAR{summary_stats["success_percentage"]}\%   \\ \hline
             \textbf{Audit Failed} & \VAR{summary_stats["failed_tests"]}  & \VAR{summary_stats["failed_percentage"]}\%    \\ \hline
          \end{tabular}
          \caption{Summary of the results of the Dockerfile audit.}
       \end{table}

       Given the results obtained, the compliance level is \colorbox{\VAR{summary_stats["compliance_color"]}}{\VAR{summary_stats["compliance_level"]}}
    \chapter{Policy Rules}
    The present audit was done with the following rules enabled:
\\
    \begin{table}[H]
        \small
          \begin{tabular}{| p{4.5cm} | p{5cm} | p{4.5cm} |}
             \hline
             \textbf{Rule Name} & \textbf{Rule Description} & \textbf{Rule Details} \\ \hline
             \BLOCK{ for rule in enabled_policy_rules["policy_rules_enabled"] }
                \tiny{\VAR{rule["type"]}} & \VAR{rule["description"]} & \footnotesize{\VAR{rule["details"]}} \\ \hline
             \BLOCK{ endfor }
          \end{tabular}
        \caption{Policy rules enforced for this audit.}
    \end{table}
    The rules violation breakdown is as follows:
    \begin{table}[H]
        \small
          \begin{tabular}{| p{7cm} | p{3cm} | p{3cm} |}
             \hline
             \textbf{Rule Name} & \textbf{Total Violation} & \textbf{Violation \%} \\ \hline
             \BLOCK{ for rule in failure_stats.keys()}
                \VAR{rule} & \VAR{failure_stats[rule]["count"]} & \VAR{failure_stats[rule]["percentage"]}\% \\ \hline
             \BLOCK{ endfor }
          \end{tabular}
        \caption{Policy rules violation breakdown.}
    \end{table}
\pagebreak
\begin{landscape}
    \chapter{Audit Details}

    In this section, the audit results for each analyzed file will be reported.

\BLOCK{ for result in audit_results["audit_results"] }

    \section{\VAR{result["filename"]}}
    Audit outcome: \BLOCK{ if result["audit-outcome"] == "pass"} \colorbox{green!50}{PASS} \BLOCK{ elif result["audit-outcome"] == "fail" } \colorbox{red!50}{FAIL} \BLOCK{ endif }
\\
    Maintainers: \texttt{\VAR{result["maintainers"]}}
\\
    \linebreak
    \BLOCK{ if result["audit-outcome"] == "fail"}
    The details for the violated rules are in the following table:
    \begin{center}
       \footnotesize
        \begin{longtable}[h!]{|p{4cm}|p{5cm}|p{7cm}|p{6cm}|}
          \hline
          \textbf{Rule Name} & \textbf{Description} & \textbf{Mitigation} & \textbf{Statement}\\ \hline
          \BLOCK{ for failed_rule_type in result["failed-tests"] }
             \BLOCK{ for failed_rule in failed_rule_type }
                \tiny{\VAR{failed_rule["type"]}} & \VAR{failed_rule["details"]} & \VAR{failed_rule["mitigations"]} & \tiny{\texttt{\VAR{failed_rule["statement"]}}} \\ \hline
             \BLOCK{ endfor }
          \BLOCK{ endfor }
          \caption{Failed policy tests for \textit{\VAR{result["filename"]}}.}
        \end{longtable}
    \end{center}
    \BLOCK{ endif }
\BLOCK{ endfor }
\end{landscape}
\end{document}